package com.yulongtian.oneProblemEveryDay.month202302;

import java.util.Arrays;

/**
 * https://leetcode.cn/problems/maximum-number-of-pairs-in-array/
 * 可 哈希表的方法
 *
 * @author yulongTian
 * @create 2023-02-16 10:29
 */
public class Test13 {
    public static void main(String[] args) {
        int[] nums = {1, 3, 2, 1, 3, 2, 2};
        System.out.println(Arrays.toString(numberOfPairs(nums)));
    }

    public static int[] numberOfPairs(int[] nums) {
        int[] cnt = new int[101];
        for (int num : nums) {
            cnt[num]++;
        }
        int[] ans = new int[2];
        for (int num : cnt) {
            ans[0] += num / 2;
            ans[1] += num % 2;
        }
        return ans;
    }


}
